<%@ page language="java" import="java.util.*,com.chj.entity.*"  pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>个人中心</title>
<link href="css/person/jquery.raty.css" rel="stylesheet" type="text/css"/>
<link href="css/bootstrap.min.css"rel="stylesheet" type="text/css">
<link href="css/evtcar.css" rel="stylesheet" type="text/css" />
<link href="css/person/userInf.css" rel="stylesheet" type="text/css" />
<link href="css/font-awesome-4.5.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="css/person/register.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="js/login.js" charset="utf-8"></script>
<script type="text/javascript" src="js/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="js/staticinfo.js" ></script>
<script type="text/javascript" src="js/person/jquery.raty.js" ></script>
<script type="text/javascript" src="js/person/UserCheck.js"></script> 
 
</head>
<body>
<!--顶部导航栏开始 -->
<%@include file="head.jsp" %>
<!--下面是中部导航栏的代码-->
<div class="nav-green nav-head" id="J_m_nav">
	<div class="nav-content">
		<div class="nav-btn "><a href="index.do">首页</a></div>
		<div class="nav-btn"><a href="ecarcharge/we_need_charge.do">我要充电</a></div>
        <div class="nav-btn active"><a href="person/person_center.do">个人中心</a></div>
        <div class="nav-btn"><a href="about_me.do">关于我们</a></div>
        <div class="nav-btn"><a href="person/person_help.do">用户帮助</a></div>
	</div>
</div>
</header>
<!--顶部导航栏结束 -->
<div class="main">
	<div class="newcontainer">
		<div id="user-card">
			<div class="inners clearfix without-side">
				<div class="head-line"><div class="name"><%=user.getUserName() %></div></div>
				<div class="user-inf">
                    <ul class="introduction">
                        <li><i class="fa fa-phone-square" style="font-size: 20px;"></i><%=user.getUserPhone() %></li><br/>
                        <li><i class="fa fa-file-text"  style="font-size: 20px;"></i><%=user.getUserEmail()%></li>
                    </ul>
                </div>
				<div class="bindings"> 
					<div class="fast-item">
							<a href="person/person_msg.do" class="btn">
									<div class="img"><i class="fa fa-calendar fa-3x"></i></div>消息提醒
							</a>
							<a href="person/person_order_manager.do" class="btn">
									<div class="img">	<i class="fa fa-shopping-cart fa-3x"></i></div>订单管理
							</a>
							<a href="person/person_ecar.do" class="btn">
									<div class="img"><i class="fa fa-desktop fa-3x"></i></div>我的电动汽车									</a>
							</a>
							<a href="person/person_update.do" class="btn without-side">
									<div class="img"><i class="fa fa-info-circle fa-3x"></i></div>我的资料
							</a>
					</div>
				</div>
			</div>
		</div>
		<div id="study-record">
					<div class="title">
						订单管理
					</div>
					<div class="inf">
						<div class="containbox">
							<div class="bar">
								<div role="tabpanel">
									<!-- Nav tabs -->
									<ul class="nav nav-tabs" role="tablist" id="myTab">
										<li role="presentation" class="active">
											<a href="#neworder" aria-controls="neworder" role="tab"
												data-toggle="tab">最新订单</a>
										</li>
										<li role="presentation">
											<a href="#oldorder" aria-controls="oldorder" role="tab"
												data-toggle="tab">历史订单</a>
										</li>
									</ul>

									<!-- Tab panes -->
									<div class="tab-content">
										<div role="tabpanel" class="tab-pane active" id="neworder">
											<table class="table table-striped" id="newOrderContent">
												<th>
													订单编号
												</th>
												<th>
													充电站名
												</th>
												<th>
													充电地点
												</th>
												<th>
													起始时间
												</th>
												<th>
													结束时间
												</th>
												<th>
													操作
												</th>
											</table>
										</div>

										<div role="tabpanel" class="tab-pane" id="oldorder">
											<table class="table table-striped" id="oldOrderContent">
												<th>
													订单编号
												</th>
												<th>
													充电站名
												</th>
												<th>
													充电地点
												</th>
												<th>
													起始时间
												</th>
												<th>
													结束时间
												</th>
												<th>
													操作
												</th>
									            </tr>
											</table>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
    </div>
    
<%@include file="footer.jsp" %>
</form>
</body>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->

<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>

</html>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"电动汽车智能充电服务系统，想充就充，一键直达！","bdMini":"2","bdMiniList":false,"bdPic":"www.ezchong.com/pic/index-img1.png;www.ezchong.com/pic/index-img2.png;www.ezchong.com/pic/index-img3.png;","bdStyle":"0","bdSize":"16"},"slide":{"type":"slide","bdImg":"6","bdPos":"right","bdTop":"238.5"},"image":{"viewList":["weixin","tsina","qzone","tqq","renren","isohu"],"viewText":"分享到：","viewSize":"16"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["weixin","tsina","qzone","tqq","renren","isohu"]}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?c8b733648de5ad25d37a909cd546fbe3";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
		
	</div>


	<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
   
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>

    <script type="text/javascript">
		$('#myTab a').click(function (e) {
			e.preventDefault()
			$(this).tab('show')
		})

		
		$(function(){
            $.ajax({
                type: "POST",
                dataType: "json",
                url: 'person/get_person_order.do',
                success: function (data) {

                    var orderList = data.orderList;
                    var orderModelList = data.orderModelList;

                    $.each(orderModelList, function(i, content){
                    	var netWork = orderModelList[i].netWork;
                        var html  = '<tr align="center">';
                            html += '<td>'+orderModelList[i].order.orderId+'</td>';
                            html += '<td>'+orderModelList[i].netWork.networkName+'</td>';
                            html += '<td>'+netWork.networkProvince+netWork.networkCity+netWork.networkArea+netWork.networkAddress+'</td>';
                            html += '<td >'+jsonDateFormat(orderModelList[i].order.orderBeginTime)+'</td>';
                            html += '<td >'+jsonDateFormat(orderModelList[i].order.orderEndTime)+'</td>';
                            html += "<td><button class=\"btn btn-primary\" onclick=\"DelButton("+"'"+orderModelList[i].order.orderPk+"'"+")\">删除</button></td>";
                            html += '</tr>';
                        $("#newOrderContent").append(html);
                    });
                },
                error: function(data) {
                    alert(data.responseText);
                 }
            });
            $.ajax({
                type: "POST",
                dataType: "json",
                url: 'person/get_person_order_old.do',
                success: function (data) {

                    var orderList = data.orderList;
                    var orderModelList = data.orderModelList;

                    $.each(orderModelList, function(i, content){
                        var netWork = orderModelList[i].netWork;
                        var html  = '<tr align="center">';
                            html += '<td>'+orderModelList[i].order.orderId+'</td>';
                            html += '<td>'+orderModelList[i].netWork.networkName+'</td>';
                            html += '<td>'+netWork.networkProvince+netWork.networkCity+netWork.networkArea+netWork.networkAddress+'</td>';
                            html += '<td >'+jsonDateFormat(orderModelList[i].order.orderBeginTime)+'</td>';
                            html += '<td >'+jsonDateFormat(orderModelList[i].order.orderEndTime)+'</td>';
                            html += "<td><button class=\"btn btn-primary\" onclick=\"DelButton("+"'"+orderModelList[i].order.orderPk+"'"+")\">删除</button></td>";
                            html += '</tr>';
                        $("#oldOrderContent").append(html);
                    });
                },
                error: function(data) {
                    alert(data.responseText);
                 }
            });
        });

		function DelButton(url){
            if (confirm('确定删除吗？')) {

                var ajax_utl = 'person/delete_person_order/'+url+'.do';
                $.ajax({
                type: "POST",
                dataType: "json",
                url: ajax_utl,
                success: function (result) {

                    if(result.flg=="true"){
                        //提交成功
                        alert('删除成功！');
                        window.location.href = 'person/person_order_manager.do';
                    }else { 
                       //提交失败
                        alert(result.errorMsg);
                    }
                },
                error: function(data) {
                    alert(data.responseText);
                 }
                 });
            }
        }
		
	function jsonDateFormat(jsonDate) {//json日期格式转换为正常格式
    try {//出自http://www.cnblogs.com/ahjesus 尊重作者辛苦劳动成果,转载请注明出处,谢谢!
        var date = new Date(jsonDate.time);
        var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
        var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
        var hours = date.getHours();
        var minutes = date.getMinutes();
        var seconds = date.getSeconds();
        var milliseconds = date.getMilliseconds();
        return date.getFullYear() + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
    } catch (ex) {//出自http://www.cnblogs.com/ahjesus 尊重作者辛苦劳动成果,转载请注明出处,谢谢!
        return "";
    }
}
	</script>
